package com.ymttest.utils.compare;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

public class TaskFactory {
	public static <T> List<Runnable> generateTasks(List<T> paramList, Consumer<T> function){
		List<Runnable> runList = new ArrayList<>();
		paramList.forEach(param->runList.add(() -> function.accept(param)));
		return runList;
	}
	
	
	public static <T> List<Runnable> generateTasks(List<T> oldParamList, List<T> newParamList,BiConsumer<T, T> function) {
		List<Runnable> runList = new ArrayList<>();
		int paramLen =Math.min(oldParamList.size(),newParamList.size());
		for(int i=0;i<paramLen;i++){
			T oldParam = oldParamList.get(i);
			T newParam = newParamList.get(i);
			runList.add(()->function.accept(oldParam,newParam));
		}
		return runList;
	}
	
}
